In [106]:
import eval_sampling as e
import itn_sampling.functions as sampling
In [179]:
reload(e)
s,f,m = e.read_trace('activation_trace', mem_width=16, mem_fraction=12)
p,silent,fire = e.activation_function(0, s, f, m)
fig = e.plot_activation_function(p, figsize=(15,8))
vlines([3.0], ymin=0.0, ymax=1.0)
print "propabilities:"
for k, v in sorted(p.iteritems()):
print " %6.2f : %1.3f (%1.3f)" % (k, v, 1./(1.+exp(-k+log(20))))
In [85]:
reload(e)
fig = e.plot_spikes(s,f)
xlim((0,1000))
fig = e.plot_membrane(m)
ylim((-10,10))
Out[85]:
In [139]:
states_smpl, fires_smpl, membrane_smpl = e.read_trace('trace', mem_width=16, mem_fraction=10)
#p_jnt = e.count_joint_states(states_smpl)
#fig = figure()
#bar(range(0,16), p_jnt)
#ylabel("p(z)")
#xlabel("z")
#for i in xrange(16):
# print "%4d : %d" % (i, p_jnt[i])
for neuron_i in xrange(4):
p,silent,fire = e.activation_function(neuron_i, states_smpl, fires_smpl, membrane_smpl)
fig = e.plot_activation_function(p, figsize=(10,5), fignum=None)
print "p = ", p
print "silent = ", silent
print "fire = ", fire
In [147]:
reload(e)
fig = e.plot_spikes(states_smpl, fires_smpl)
ylim((-0.5,3.5))
#xlim((0, 1000))
fig = e.plot_membrane(membrane_smpl)
#xlim((0, 1000))
In [181]:
reload(e)
states_smpl, fires_smpl, membrane_smpl = e.read_trace('trace', mem_width=16, mem_fraction=10)
W = np.array([[ 0.0, 1.5, 1.0, -1.0],
[ 1.5, 0.0, 1.0, -1.0],
[ 1.0, 1.0, 0.0, 0.5],
[-1.0, -1.0, 0.5, 0.0]])
b = np.array([-1.0, -0.5, -2.0, -1.5])
ext = np.array([0.0, 0.0, 0.0, 0.0])
dist = sampling.BoltzmannDistribution(W, b, ext)
p_jnt_norm = sum(p_jnt)
print p_jnt
states_smpl_ar = array(states_smpl)
print states_smpl_ar
print "KL = ", dist.KL_to_samples(states_smpl_ar)
print dist.p_sample
fig = figure(figsize=(10,6))
bar(range(16), dist.p_ana, width=0.3, label='theory')
#bar(np.array(range(16))+0.3, [float(x)/float(p_jnt_norm) for x in p_jnt], width=0.3, color='red', label='VHDL')
bar(np.array(range(16))+0.3, dist.p_sample, width=0.3, color='red', label='VHDL')
legend(loc='best')
Out[181]:
In [173]:
import copy
fig_joints_2ms = copy.copy(fig)
savefig('joints_cmp.eps', fig_joints_2ms)